from xinan_ui.proxy.base_page import PageHandle
from xinan_ui.tools.read_yml_xn import ReadYaml
import time
import logging
data_eles = ReadYaml(r'D:\testLi\PythonWork\xinan_ui\config\jdzapp.yml').read_yaml()['普通卖出']


class PtSell(PageHandle):
    def __init__(self,driver):
        self.driver=driver
        super().__init__(self.driver)

    def pt_sell(self,code,amout):
        #点击卖出入口
        self.click_button(data_eles[0]['卖出入口按钮'])
        time.sleep(2)
        #点击买入标题
        self.click_button(data_eles[1]['买入标题'])
        time.sleep(1)
        #点击卖出标题
        self.click_button(data_eles[2]['卖出标题'])
        time.sleep(1)
        #点击股票代码卖出输入框
        self.click_button(data_eles[3]['股票代码卖出输入框'])
        time.sleep(1)
        #输入股票代码
        self.input_element(data_eles[3]['股票代码卖出输入框'],code)
        time.sleep(1)
        #选择目标代码
        self.click_button(data_eles[4]['目标代码选择区域'])
        time.sleep(1)
        #输入卖出数量
        self.input_element(data_eles[5]['数量输入框'],amout)
        time.sleep(1)
        #点击卖出按钮
        self.click_button(data_eles[6]['卖出按钮'])
        time.sleep(2)
        #点击卖出委托弹窗确定卖出按钮
        self.click_button(data_eles[7]['卖出委托弹窗确定卖出按钮'])
        time.sleep(2)
        #获取系统弹窗文案
        data=self.get_text(data_eles[9]['卖出委托弹窗提示文案'])
        time.sleep(2)
        #点击系统信息确定按钮
        self.click_button(data_eles[8]['系统信息确定按钮'])
        time.sleep(2)
        #返回上一级
        self.click_button(data_eles[10]['返回上级'])
        time.sleep(1)
        return data